package com.itheima.mapper;

import com.itheima.pojo.Book;
import com.itheima.pojo.vo.BookVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BookMapper {
    @Insert("insert into book(name, author, cover_img, category_id, introduction, bookshelf_id, create_user, create_time, update_time) " +
            "values (#{name},#{author},#{coverImg},#{categoryId},#{introduction},#{bookshelfId},#{createUser},#{createTime},#{updateTime})")
    void addBook(Book book);

    List<BookVo> list(Integer categoryId, Integer bookshelfId,String name);
    @Update("update book set name=#{name},author=#{author},cover_img=#{coverImg},introduction=#{introduction},category_id=#{categoryId},bookshelf_id=#{bookshelfId},create_user=#{createUser},update_time=#{updateTime} where id=#{id}")
    void updateBook(Book book);
    @Delete("delete from book where id=#{id}")
    void deleteBook(Integer id);
}
